package com.imooc.sell.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.extern.slf4j.Slf4j;

/**
 * 转换器工具类
 */
@Slf4j
public class Convertors {

    /**
     * 对象转json
     */
    public static String ob2Json(Object o) {
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        try {
            return gson.toJson(o);
        } catch (Exception e) {
            log.error("Convertors:json转换错误");
        }
        return null;
    }
}
